
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<link rel="stylesheet" href="layui/css/layui.css" />
<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
</head>
<body>
 	<div style="width: 475px;margin:auto;font-size: 25px;text-align: center">用户登录</div>
	<br/>
	<form class="layui-form" style="width:460px;margin:auto;">
		<div class="layui-form-item">
			<label class="layui-form-label">账号:</label>
			<div class="layui-input-inline">
				<input id="userPhone" style="width: 210px" type="text"
					required lay-verify="required" placeholder="请输入用户名"
					autocomplete="off" class="layui-input"></input>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">密码:</label>
			<div class="layui-input-inline">
				<input id="userPassword" type="password" style="width: 210px"
					 required lay-verify="required" placeholder="请输入密码"
					autocomplete="off" class="layui-input"></input>
			</div>
		</div>
	</form>
	<div class="layui-form-item" style="width:230px;margin:auto">
		<button id="login" class="layui-btn"
				style="width: 98px">登录</button>
		<button class="layui-btn" lay-submit
				style="width: 98px">立即注册</button>
	</div>
</body>
<script type="text/javascript">
    //代码错误提示
    Myerror=function(XMLHttpresponse){
        if(XMLHttpresponse.status=="404")
            alert("找不到页面");
        else if(XMLHttpresponse.status=="500")
            alert("服务有误");
        else
            alert("其他错误");
    }

    $("#login").click(function () {
        $.ajax({
            url: "userjudgeLogin",
            data:{userPhone:$("#userPhone").val(),userPassword:$("#userPassword").val()},
            type:"post",
			dataType:"text",
            success:function(result){
                if(result.trim()==""){
                    window.location.href="http://localhost:8080/bookselectAllBook";
                }else{
                    alert(result);
                }
            },
            error:Myerror
        })
    })
</script>
</html>